<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增兽药库存')" />
	<th:block th:include="include :: select2-css" />

</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
	<form class="form-horizontal m" id="form-ncDrugs-add">
		<!--药品ID-->
		<input id="treeId" name="treeId" type="hidden" value="1"/>
		<input id="yaoId" name="yaoId" type="hidden" value="1"/>
		<div class="form-group">`
			<label class="col-sm-3 control-label">药品名称：</label>
			<div class="col-sm-8">
				<div class="input-group">
					<input class="form-control" type="text" onclick="selectYaoTree()" id="treeName" readonly="true"  name="drugName" />
					<span class="input-group-addon"><i class="fa fa-search"></i></span>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">生产厂家：</label>
			<div class="col-sm-8">
				<input id="factory" name="factory" class="form-control" type="text">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">合格证：</label>
			<div class="col-sm-8">
				<select name="isHege" required class="form-control m-b" th:with="type=${@dict.getType('is_hege')}">
					<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">入库数量：</label>
			<div class="col-sm-8">
				<input id="inputAmount" name="inputAmount" class="form-control" type="number">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">单位规格：</label>
			<div class="col-sm-8">
				<select name="unit" class="form-control m-b" th:with="type=${@dict.getType('normal_unit')}">
					<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">入库时间：</label>
			<div class="col-sm-8">
				<input id="createTime" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss" name="createTime"
					   required th:value="*{#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd HH:mm:ss')}"
					   class="form-control"
					   type="text" th:class="time-input">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">有效期：</label>
			<div class="col-sm-8">
				<input id="validDate" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss" name="validDate"
					   required th:value="*{#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd HH:mm:ss')}" class="form-control"
					   type="text" th:class="time-input">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">采购人：</label>
			<div class="col-sm-8">
				<select id="purchaser" name="purchaser" class="form-control select2-multiple" >
					<option th:each="user:${users}" th:value="${user.loginName}" th:text="${user.loginName}"></option>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">备注：</label>
			<div class="col-sm-8">
				<textarea rows="4" name="remark"  class="form-control" type="text"></textarea>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">功能主治：</label>
			<div class="col-sm-8">
				<input id="mainFunction" name="mainFunction" class="form-control" type="text">
			</div>
		</div>
	</form>
</div>
<div th:include="include::footer"></div>
<th:block th:include="include :: select2-js" />
<script type="text/javascript">

	var prefix = ctx + "system/ncDrugs";

	var yao_prefix = ctx + "system/ncYaoClass";

	//加载药品树start
	function selectYaoTree() {
		var options = {
			title: '药品选择',
			width: "380",
			url: yao_prefix + "/selectYaoTree/"+ $("#treeId").val(),
			callBack: doSubmit
		};
		$.modal.openOptions(options);

	}
	function doSubmit(index, layero) {
		var body = layer.getChildFrame('body', index);
		$("#treeId").val(body.find('#treeId').val());
		$("#treeName").val(body.find('#treeName').val());
		$("#yaoId").val(body.find('#treeId').val());
		layer.close(index);
	}
	//加载药品树end


	$("#form-ncDrugs-add").validate({
        rules: {
            inputAmount: {
                required: true,
                digits: true
            }

        },
        messages: {
            inputAmount: "入库数必须为正整数",
        },
        focusCleanup: true
	});

	function submitHandler() {
		if ($.validate.form()) {
			$.operate.save(prefix + "/add", $('#form-ncDrugs-add').serialize());
		}
	}
</script>
</body>
</html>
